package com.wanxi.service.impl;

import com.wanxi.dao.NavDao;
import com.wanxi.model.NavModel;
import com.wanxi.model.ResultModel;
import com.wanxi.service.NavService;
import com.wanxi.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 杨金乾
 */
@Service
public class NavServiceImpl implements NavService {
    @Autowired
    NavDao navDao;
    @Override
    public ResultModel enable(NavModel navModel) {
        return null;
    }

    @Override
    public ResultModel add(NavModel navModel) {
        SnowflakeIdWorker snowflakeIdWorker=new SnowflakeIdWorker(WorkId.WORK_ID);
        navModel.setId(snowflakeIdWorker.nextId());
        return ResultModel.getResult(navDao.add(navModel));
    }

    @Override
    public ResultModel update(NavModel navModel) {
        return null;
    }

    @Override
    public ResultModel delete(NavModel navModel) {
        return null;
    }

    @Override
    public ResultModel findById(NavModel navModel) {
        return null;
    }

    @Override
    public ResultModel findAll(NavModel navModel) {
        navModel.setLimit(10);
        navModel.setPage((navModel.getPage()-1)*10);
        return ResultModel.getResult(navDao.findAll(navModel), navDao.count(navModel));
    }

    @Override
    public ResultModel count(NavModel navModel) {
        return ResultModel.getResult(navDao.count(navModel));
    }

    @Override
    public ResultModel isShow(NavModel navModel) {
        return ResultModel.getResult(navDao.isShow(navModel));
    }

    @Override
    public ResultModel isRecommend(NavModel navModel) {
        return null;
    }

    @Override
    public ResultModel whereShow(NavModel navModel) {
        return null;
    }
}
